<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\CarRecordController;
use App\Http\Controllers\Api\DriverController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// 微信登录
Route::post('/wx-login', [AuthController::class, 'wxLogin']);

// 司机相关接口
Route::get('/drivers', [DriverController::class, 'index']);
Route::get('/driver-info', [DriverController::class, 'getDriverInfo']);

// 用车记录相关接口
Route::get('/car-records', [CarRecordController::class, 'index']);
Route::post('/car-records', [CarRecordController::class, 'store']);
Route::get('/car-records/{id}', [CarRecordController::class, 'show']);
Route::put('/car-records/{id}', [CarRecordController::class, 'update']);
Route::delete('/car-records/{id}', [CarRecordController::class, 'destroy']);

// 调车人列表
Route::get('/dispatchers', [CarRecordController::class, 'getDispatchers']);

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
